home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / hsclib / hscprc.h < prev    next >
C/C++ Source or Header  |  1996-11-15  |  16KB  |  397 lines

  1. /*
  2.  * hsclib/hscprc.h
  3.  *
  4.  * hsc process structure
  5.  *
  6.  * Copyright (C) 1995,96  Thomas Aglassinger
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  */
  23.  
  24. #ifndef HSC_HSCPRC_H
  25. #define HSC_HSCPRC_H
  26.  
  27. #include <time.h>
  28.  
  29. #include "hsclib/ldebug.h"
  30. #include "hsclib/tag.h"
  31.  
  32. #include "hscprj/project.h"
  33.  
  34. /*
  35.  * system-dependant defines
  36.  */
  37. #ifdef AMIGA
  38. #define CONFIG_FILE "hsc.prefs"
  39. #define OPTION_FILE "hsc.options", "env:hsc.options"
  40. #define CONFIG_PATH "PROGDIR:"
  41.  
  42. #elif defined BEBOX
  43. #define CONFIG_FILE "hsc.prefs"
  44. #define CONFIG_PATH ""          /* TODO: where to search for prefs */
  45. #define OPTION_FILE "hsc.options"
  46. #define UNIX                    /* utilise POSIX-layer of BeOS */
  47.  
  48. #elif defined UNIX
  49. #define CONFIG_FILE "hsc.prefs"
  50. #define CONFIG_PATH "/usr/local/lib/"
  51. #define OPTION_FILE "hsc.options"
  52.  
  53. #elif defined WINNT
  54. #define CONFIG_FILE "hsc.prefs"
  55. #define CONFIG_PATH "\\"
  56. #define OPTION_FILE "hsc.options"
  57.  
  58. #elif defined MSDOS
  59. #define CONFIG_FILE "HSC.PRE"
  60. #define CONFIG_PATH "\\"
  61. #define OPTION_FILE "HSC.OPT"
  62.  
  63. #else
  64. #error "Operating system not supported: config-file/path"
  65. #endif
  66.  
  67. #if (!defined MSDOS) & ((defined WINNT))
  68. /* handle several OS-es same as MSDOS */
  69. #define MSDOS 1
  70. #endif
  71.  
  72. /* step sizes for expstr's */
  73. #define ES_STEP_RMTSTR   256    /* tag_macr.c */
  74. #define ES_STEP_MACRO   1024    /* tag_macr.c */
  75. #define ES_STEP_INFILE  4096    /* input file buffer */
  76.  
  77. /*
  78.  * modes for syntax check
  79.  */
  80. #define MODE_PEDANTIC 1
  81. #define MODE_NORMAL   2
  82. #define MODE_RELAXED  3
  83.  
  84. /*
  85.  * modes for attribute quotes
  86.  */
  87. #define QMODE_KEEP   1          /* keep quotes from input */
  88. #define QMODE_DOUBLE 2          /* always use double quotes (compatible) */
  89. #define QMODE_SINGLE 3          /* always use single quotes */
  90. #define QMODE_NONE   4          /* never use any quotes (compact) */
  91.  
  92. /*
  93.  * modes for special characters/entity extraction
  94.  */
  95. #define EMODE_KEEP     1        /* do not replace */
  96. #define EMODE_REPLACE  2        /* replace by prefered value */
  97.                                 /*   (depends wheter if a PREFNUM was used */
  98.                                 /*   within $DEFENT) */
  99. #define EMODE_NUMERIC  3        /* always replace by numeric ({) */
  100. #define EMODE_SYMBOLIC 4        /* always replace by symbolic (ü) */
  101.  
  102. /*
  103.  * misc. defines for files & envvars
  104.  */
  105. #define ENV_HSCPATH    "HSCPATH"        /* envvar that contains path for prefs */
  106. #define ENV_HSCSALARY  "HSCSALARY"      /* contains salary of user */
  107. #define ENV_HSCUSER    "HSCUSER_PATH"   /* to substitute "~/" */
  108. #define ENV_HSCUSERS   "HSCUSERS_PATH"  /* to substitute "~" */
  109. #define ENV_HSCROOT    "HSCROOT_PATH"   /* to substitute "/" */
  110.  
  111. #define SPECIAL_FILE_ID "::s::" /* used as prefix in filename for */
  112.                                    /* internal (pseudo-)files (macros,init) */
  113. #define PARENT_FILE_ID  "::p::" /* used as prefix in filename if */
  114.               /* parent file on input-stack should be used for message-pos. */
  115. #define FILENAME_STDIN "STDIN"  /* pseudo-filename for stdin */
  116.  
  117. /* prefix char used for special hsc-tags  */
  118. #define HSC_SPECIAL_PREFIX "$"
  119.  
  120. /* attribute that holds "click here" words */
  121. #define CLICK_HERE_ATTR     "HSC.CLICK-HERE"
  122. #define COLOR_NAMES_ATTR    "HSC.COLOR-NAMES"
  123. #define ANCHOR_ATTR         "HSC.ANCHOR"
  124. #define RESULT_ATTR         "HSC.EXEC.RESULT"
  125. #define FILESIZEFORMAT_ATTR "HSC.FORMAT.FILESIZE"
  126. #define TIMEFORMAT_ATTR     "HSC.FORMAT.TIME"
  127. #define LINEFEED_ATTR       "HSC.LF"
  128.  
  129. /* attribute that hold condition on <$if/$elseif> */
  130. #define CONDITION_ATTR "COND"
  131.  
  132. /* attribute that tells operating system */
  133. #define SYSTEM_ATTR     "HSC.SYSTEM"
  134. #ifdef AMIGA
  135. #define SYSTEM_ATTR_ID "AMIGA"
  136.  
  137. #elif defined BEBOX
  138. #define SYSTEM_ATTR_ID "BEBOX"
  139.  
  140. #elif defined UNIX
  141. #define SYSTEM_ATTR_ID "UNIX"
  142.  
  143. #elif defined WINNT
  144. #define SYSTEM_ATTR_ID "WINNT"
  145.  
  146. #elif defined MSDOS
  147. #define SYSTEM_ATTR_ID "LLIBLLIK"       /* "kill bill" backwards, stupid! */
  148.  
  149. #else
  150. #error "system not supported: SYSTEM_ATTR_ID"
  151. #endif
  152.  
  153. typedef LONG HSCMSG_ID;         /* hsc message id */
  154. typedef LONG HSCMSG_CLASS;      /* hsc message class */
  155.  
  156. /*
  157.  * hsc process structure
  158.  */
  159. typedef struct hscprocess
  160. {
  161.     INFILE *inpf;               /* current input file */
  162.     DLLIST *inpf_stack;         /* stack of nested input files */
  163.     DLLIST *deftag;             /* defined tags and macros */
  164.     DLLIST *defattr;            /* defined attributes */
  165.     DLLIST *defent;             /* defined special charcters & entities */
  166.     DLLIST *container_stack;    /* stack of container-tags currently open */
  167.     DLLIST *include_dirs;       /* include directories */
  168.     HSCPRJ *project;            /* project data */
  169.     DLLIST *idrefs;             /* list of references to local IDs */
  170.     EXPSTR *destdir;            /* destination root directory */
  171.     EXPSTR *reldir;             /* relative destination directory */
  172.     EXPSTR *tmpstr;             /* temp. string used by several functions */
  173.     EXPSTR *rmt_str;            /* temp. string used for macro text */
  174.     EXPSTR *curr_msg;           /* current message */
  175.     EXPSTR *curr_ref;           /* current reference message */
  176.     EXPSTR *iconbase;           /* base URI for icons */
  177.     time_t start_time;          /* time process has been started */
  178.  
  179.     DLLIST *select_stack;       /* stack for results of <$select> */
  180.     EXPSTR *if_stack;           /* stack for results of <$if> */
  181.  
  182.     EXPSTR *tag_name_str;       /* strings for communication with tag-handlers */
  183.     EXPSTR *tag_attr_str;
  184.     EXPSTR *tag_close_str;
  185.  
  186.     STRPTR filename_document;   /* document-name to be stored in project */
  187.  
  188.     BOOL *msg_ignore;           /* messages to be ignored */
  189.     BOOL msg_ignore_notes;      /* message-classes to be ignores */
  190.     BOOL msg_ignore_style;
  191.     BOOL msg_ignore_port;
  192.     HSCMSG_CLASS *msg_class;    /* messages with remaped classes */
  193.     ULONG msg_count;            /* numer of messages occured until now */
  194.  
  195.     BOOL chkid;                 /* flag: check existence of URIs/IDs */
  196.     BOOL chkuri;
  197.     BOOL compact;               /* flag: create compact output */
  198.     BOOL debug;                 /* flag: display debuging info */
  199.     BOOL getsize;               /* flag: get size of images/embedded docs */
  200.  
  201.     BOOL htmlonly;              /* flag: disable hsc-extensions */
  202.     BOOL jens;                  /* flag: enable some experimental features */
  203.     BOOL jerkvalues;            /* flag: interpret jerk values */
  204.     BOOL rplc_ent;              /* flag: replace special chars */
  205.     BOOL rplc_quote;            /* flag: replace quotes in text by """ */
  206.     BOOL smart_ent;             /* flag: replace special entities "<>&" */
  207.     BOOL strip_cmt;             /* flag: strip SGML-comments */
  208.     BOOL strip_ext;             /* flag: strip external references */
  209.     BOOL strip_badws;           /* flag: strip bad white spaces */
  210.  
  211.     BOOL suppress_output;       /* flag: TRUE, until outputable data occure */
  212.     BOOL docbase_set;           /* <BASE HREF=".."> occured */
  213.     BOOL inside_pre;            /* inside preformatted tag <PRE> & Co. */
  214.     BOOL inside_anchor;         /* inside anchor-tag <A> */
  215.     BOOL inside_title;          /* inside title-tag <TITLE> */
  216.     BOOL prostitute;            /* use "prostitute" or "jerk"? */
  217.  
  218.     BOOL fatal;                 /* fatal error occured; abort process */
  219.  
  220.     LONG tag_call_id;
  221.     ULONG prev_status_line;
  222.     LONG prev_heading_num;      /* number of previous heading */
  223.     LONG entmode;               /* entity replace mode */
  224.     LONG quotemode;             /* quotes to use as output quotes */
  225.  
  226.     STRPTR click_here_str;      /* keywords for click-here syndrome */
  227.     STRPTR color_names;         /* predifined names for colors */
  228.     STRPTR strip_tags;          /* tags that should be stripped */
  229.     EXPSTR *whtspc;             /* white spaces buffered */
  230.     BOOL strip_next_whtspc;     /* flag: strip next whtite space
  231.                                  * set by parse_tag(), if strip_badws = TRUE */
  232.     BOOL strip_next2_whtspc;    /* flag: strip next but one white space */
  233.     /* status callbacks */
  234.       VOID(*CB_status_misc) (struct hscprocess * hp, STRPTR s);
  235.     /* called for verbose messages */
  236.       VOID(*CB_status_line) (struct hscprocess * hp);
  237.     /* called after new line */
  238.       VOID(*CB_status_file_begin) (struct hscprocess * hp, STRPTR filename);
  239.     /* called when new file is going to be loaded */
  240.       VOID(*CB_status_file_end) (struct hscprocess * hp);
  241.     /* called after file has fully been processed */
  242.  
  243.     /* message callbacks */
  244.       VOID(*CB_message) (struct hscprocess * hp,
  245.                          HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
  246.                          STRPTR fname, ULONG x, ULONG y,
  247.                          STRPTR msg_text);
  248.       VOID(*CB_message_ref) (struct hscprocess * hp,
  249.                              HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
  250.                              STRPTR fname, ULONG x, ULONG y,
  251.                              STRPTR msg_text);
  252.  
  253.     /* syntax elements callbacks */
  254.       VOID(*CB_start_tag) (struct hscprocess * hp,
  255.           HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
  256.       VOID(*CB_end_tag) (struct hscprocess * hp,
  257.           HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
  258.       VOID(*CB_text) (struct hscprocess * hp,
  259.                       STRPTR white_spaces, STRPTR text);
  260.       VOID(*CB_id) (struct hscprocess * hp,
  261.                     HSCATTR * attr, STRPTR id);
  262. }
  263. HSCPRC;
  264.  
  265. /*
  266.  * global funcs
  267.  */
  268. #ifndef NOEXTERN_HSC_HSCPRC
  269.  
  270. #define anyWhtspc(hp) (estrlen(hp->whtspc))
  271.  
  272. extern VOID del_hscprc(HSCPRC * hp);
  273. extern HSCPRC *new_hscprc(void);
  274. extern VOID reset_hscprc(HSCPRC * hp);
  275.  
  276. /* set-methodes for callbacks */
  277. extern VOID hsc_set_status_file_begin(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp, STRPTR filename));
  278. extern VOID hsc_set_status_file_end(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp));
  279. extern VOID hsc_set_status_line(HSCPRC * hp, VOID(*status_line) (HSCPRC * hp));
  280. extern VOID hsc_set_status_misc(HSCPRC * hp, VOID(*status_misc) (HSCPRC * hp, STRPTR s));
  281. extern VOID hsc_set_message(HSCPRC * hp,
  282.                             VOID(*message) (struct hscprocess * hp,
  283.                                             HSCMSG_CLASS msg_class,
  284.                                             HSCMSG_ID,
  285.                                             STRPTR fname, ULONG x, ULONG y,
  286.                                             STRPTR msg_text));
  287. extern VOID hsc_set_message_ref(HSCPRC * hp,
  288.                                 VOID(*message_ref) (struct hscprocess * hp,
  289.                                                     HSCMSG_CLASS msg_class,
  290.                                                     HSCMSG_ID msg_id,
  291.                                                     STRPTR fname,
  292.                                                     ULONG x, ULONG y,
  293.                                                     STRPTR msg_text));
  294. extern VOID hsc_set_start_tag(HSCPRC * hp,
  295.                               VOID(*CB_start_tag) (struct hscprocess * hp,
  296.                                                    HSCTAG * tag,
  297.                                                    STRPTR tag_name,
  298.                                                    STRPTR tag_attr,
  299.                                                    STRPTR tag_close));
  300. extern VOID hsc_set_end_tag(HSCPRC * hp,
  301.                             VOID(*CB_end_tag) (struct hscprocess * hp,
  302.                                                HSCTAG * tag,
  303.                                                STRPTR tag_name,
  304.                                                STRPTR tag_attr,
  305.                                                STRPTR tag_close));
  306. extern VOID hsc_set_text(HSCPRC * hp,
  307.                          VOID(*CB_text) (struct hscprocess * hp,
  308.                                          STRPTR white_spaces, STRPTR text));
  309. extern VOID hsc_set_id(HSCPRC * hp,
  310.                        VOID(*id) (struct hscprocess * hp,
  311.                                   HSCATTR * attr, STRPTR id));
  312.  
  313. /* set-methodes for flags */
  314. extern VOID hsc_set_chkid(HSCPRC * hp, BOOL new_chkid);
  315. extern VOID hsc_set_chkuri(HSCPRC * hp, BOOL new_chkuri);
  316. extern VOID hsc_set_compact(HSCPRC * hp, BOOL new_compact);
  317. extern VOID hsc_set_debug(HSCPRC * hp, BOOL new_debug);
  318. extern VOID hsc_set_getsize(HSCPRC * hp, BOOL new_getsize);
  319. extern VOID hsc_set_htmlonly(HSCPRC * hp, BOOL new_jens);
  320. extern VOID hsc_set_jens(HSCPRC * hp, BOOL new_jens);
  321. extern VOID hsc_set_jerkvalues(HSCPRC * hp, BOOL new_jens);
  322. extern VOID hsc_set_rplc_ent(HSCPRC * hp, BOOL new_rplc_ent);
  323. extern VOID hsc_set_rplc_quote(HSCPRC * hp, BOOL new_rplc_quote);
  324. extern VOID hsc_set_smart_ent(HSCPRC * hp, BOOL new_smart_ent);
  325. extern VOID hsc_set_strip_badws(HSCPRC * hp, BOOL new_strip_badws);
  326. extern VOID hsc_set_strip_cmt(HSCPRC * hp, BOOL new_strip_cmt);
  327. extern VOID hsc_set_strip_ext(HSCPRC * hp, BOOL new_strip_ext);
  328.  
  329. /* set-methodes for values */
  330. extern BOOL hsc_set_destdir(HSCPRC * hp, STRPTR dir);
  331. extern BOOL hsc_set_reldir(HSCPRC * hp, STRPTR fname);
  332. extern BOOL hsc_set_iconbase(HSCPRC * hp, STRPTR uri);
  333. extern BOOL hsc_set_strip_tags(HSCPRC * hp, STRPTR taglist);
  334. extern BOOL hsc_set_filename_document(HSCPRC * hp, STRPTR filename);
  335. extern VOID hsc_set_quote_mode(HSCPRC * hp, LONG new_mode);
  336. extern VOID hsc_set_entity_mode(HSCPRC * hp, LONG new_mode);
  337.  
  338. /* methodes for include-directories */
  339. extern BOOL hsc_add_include_directory(HSCPRC * hp, STRPTR dir);
  340. extern VOID hsc_clr_include_directory(HSCPRC * hp);
  341.  
  342. /* get-methodes for flags */
  343. extern BOOL hsc_get_chkid(HSCPRC * hp);
  344. extern BOOL hsc_get_chkuri(HSCPRC * hp);
  345. extern BOOL hsc_get_compact(HSCPRC * hp);
  346. extern BOOL hsc_get_debug(HSCPRC * hp);
  347. extern BOOL hsc_get_getsize(HSCPRC * hp);
  348. extern BOOL hsc_get_htmlonly(HSCPRC * hp);
  349. extern BOOL hsc_get_jerkvalues(HSCPRC * hp);
  350. extern BOOL hsc_get_jens(HSCPRC * hp);
  351. extern BOOL hsc_get_rplc_ent(HSCPRC * hp);
  352. extern BOOL hsc_get_rplc_quote(HSCPRC * hp);
  353. extern BOOL hsc_get_smart_ent(HSCPRC * hp);
  354. extern BOOL hsc_get_strip_badws(HSCPRC * hp);
  355. extern BOOL hsc_get_strip_cmt(HSCPRC * hp);
  356. extern BOOL hsc_get_strip_ext(HSCPRC * hp);
  357.  
  358. /* get-methodes for internal flags */
  359. extern BOOL hsc_get_fatal(HSCPRC * hp);
  360. extern BOOL hsc_get_inside_anchor(HSCPRC * hp);
  361. extern BOOL hsc_get_inside_pre(HSCPRC * hp);
  362. extern BOOL hsc_get_suppress_output(HSCPRC * hp);
  363.  
  364. /* get-methodes for values */
  365. extern STRPTR hsc_get_destdir(HSCPRC * hp);
  366. extern STRPTR hsc_get_reldir(HSCPRC * hp);
  367. extern STRPTR hsc_get_iconbase(HSCPRC * hp);
  368.  
  369. /* get-methodes for internal values */
  370. extern STRPTR hsc_get_click_here_str(HSCPRC * hp);
  371. extern STRPTR hsc_get_file_name(HSCPRC * hp);
  372. extern ULONG hsc_get_file_line(HSCPRC * hp);
  373. extern ULONG hsc_get_file_column(HSCPRC * hp);
  374. extern ULONG hsc_get_msg_count(HSCPRC * hp);
  375.  
  376. /* methodes for messages */
  377. extern BOOL hsc_set_msg_ignore_notes(HSCPRC * hp, BOOL value);
  378. extern BOOL hsc_set_msg_ignore_style(HSCPRC * hp, BOOL value);
  379. extern BOOL hsc_set_msg_ignore_port(HSCPRC * hp, BOOL value);
  380. extern BOOL hsc_set_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id, BOOL value);
  381. extern BOOL hsc_get_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id);
  382. extern BOOL hsc_set_msg_class(HSCPRC * hp, HSCMSG_ID msg_id, HSCMSG_CLASS msg_class);
  383. extern HSCMSG_CLASS hsc_get_msg_class(HSCPRC * hp, HSCMSG_ID msg_id);
  384. extern VOID hsc_clear_msg_ignore(HSCPRC * hp);
  385. extern VOID hsc_reset_msg_class(HSCPRC * hp);
  386.  
  387. /* output function */
  388. extern STRPTR compactWs(HSCPRC * hp, STRPTR ws);
  389. extern BOOL hsc_output_text(HSCPRC * hp, STRPTR wspc, STRPTR text);
  390.  
  391. /* misc. functions */
  392. extern BOOL hsc_standard_nomem_handler(size_t size);
  393.  
  394. #endif /* NOEXTERN_HSC_HSCPRC */
  395. #endif /* HSC_HSCPRC_H */
  396.  
  397.